package main;

import java.util.Date;

import metier.Stock;

public class Vente {
	
	private static Vente instance = null;
	
	private int prev_vente_sauc_sec;
	public int getPrev_vente_sauc_sec() { return prev_vente_sauc_sec; }
	public void setPrev_vente_sauc_sec(int prevVenteSaucSec) { prev_vente_sauc_sec = prevVenteSaucSec; }

	private int prev_vente_sauc_sec_n;
	public int getPrev_vente_sauc_sec_n() {	return prev_vente_sauc_sec_n;}
	public void setPrev_vente_sauc_sec_n(int prevVenteSaucSecN) { prev_vente_sauc_sec_n = prevVenteSaucSecN;}
	
	private Vente() { }
	
	public static Vente getInstance()
	{
		if (instance == null)
			instance = new Vente();
		
		return instance;
	}
	
	
	public void vendre_sec(Date date_vente)
	{
		int vente = prev_vente_sauc_sec;
		if ((date_vente.getMonth() == 7) || (date_vente.getMonth() == 8))
			vente += (prev_vente_sauc_sec*0.2);
		
		if ((Stock.getInstance().getSauc_sec() - vente) > 0)
		{
			Stock.getInstance().setSauc_sec(Stock.getInstance().getSauc_sec() - vente);
			Stock.getInstance().setVente_sauc_sec(Stock.getInstance().getVente_sauc_sec() + vente);
			System.out.println(date_vente.getDate() + "/" + date_vente.getMonth() + "/" + date_vente.getYear() + " : Vente de " + vente + " saucissons sec.");
		}
		else
		{
			System.out.println("************************************************************************************************************");
			System.out.println(date_vente.getDate() + "/" + date_vente.getMonth() + "/" + date_vente.getYear() + " : Stock insuffisant pour la vente de saucissons sec.");
			System.out.println("************************************************************************************************************");
		}
		
	}
	
	public void vendre_noix(Date date_vente)
	{
		int vente = prev_vente_sauc_sec_n;
		if ((date_vente.getMonth() == 7) || (date_vente.getMonth() == 8))
			vente += (prev_vente_sauc_sec_n*0.2);
		
		if ((Stock.getInstance().getSauc_sec_noix() - vente) > 0)
		{
			Stock.getInstance().setSauc_sec(Stock.getInstance().getSauc_sec() - vente);
			Stock.getInstance().setVente_sauc_noix(Stock.getInstance().getVente_sauc_noix() + vente);
			System.out.println(date_vente.getDate() + "/" + date_vente.getMonth() + "/" + date_vente.getYear() + " : Vente de " + vente + " saucissons sec aux noix.");
		}
		else
		{
			System.out.println("************************************************************************************************************");
			System.out.println(date_vente.getDate() + "/" + date_vente.getMonth() + "/" + date_vente.getYear() + " : Stock insuffisant pour la vente de saucissons sec aux noix.");
			System.out.println("************************************************************************************************************");
		}
	}

	
	
}
